package com.news.cloud.service;

import com.news.cloud.exception.ServerTechnicalException;
import com.news.cloud.jpa.domain.Provider;
import com.news.cloud.jpa.repository.ProviderRepository;
import com.news.cloud.web.model.ProviderPageResponse;
import com.news.cloud.web.model.ProviderResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by hiephn on 2014/09/01.
 */
@Service
public class ProviderService {

    @Autowired
    private ProviderRepository providerRepo;

    public ProviderPageResponse get() throws ServerTechnicalException {
        List<Provider> providers = providerRepo.findAll();
        ProviderPageResponse providerPageResponse = new ProviderPageResponse();
        providerPageResponse.from(providers, ProviderResponse.class);
        return providerPageResponse;
    }
}
